package com.iraeta.service.sys.impl;

import cn.hutool.core.date.DateUtil;
import com.iraeta.dao.sys.LoginlogDao;
import com.iraeta.entity.Loginlog;
import com.iraeta.service.sys.LoginLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class LoginLogServiceImpl implements LoginLogService {
    @Resource
    LoginlogDao loginlogDao;

    @Override
    public void addLoginLog(Loginlog loginlog) {
        loginlogDao.insertSelective(loginlog);
    }

    @Override
    public List<Loginlog> listLoginLog(String startDate, String endDate) {
        if(endDate != null){
            endDate = DateUtil.format( DateUtil.offsetDay(DateUtil.parseDate(endDate), 1), "yyyy-MM-dd");
        }
        return loginlogDao.selectByDate(startDate, endDate);
    }
}
